package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import java.util.Objects;
import lombok.Getter;

/**
 * @Author shian
 * @create 2020-03-09 13:37
 * @Description
 */
@Getter
public enum AppOperateProcessEnum {
    /**
     * 应用的操作流程
     */
    APPLY_TRIAL_INDEX(1, "申请试用->开启、关闭"),
    APPLY_OPEN_INDEX(2, "申请开通->开启、关闭"),
    TRIAL_OPEN_UPGRADERENEWAL_INDEX(3, "试用->开通->升级续费"),
    TRIAL_OPEN_INDEX(4, "试用->开通"),
    START_INDEX(5, "开启、关闭"),
    INSTALL(6, "安装->开启、关闭"),
    AUTHORIZE(7, "开通授权、取消授权"),
    ONLY_NSTALL(8, "仅安装"),
    OUTSIDE(9, "开通授权、取消授权"),
    UNKNOW(10000, "unknow");

    private Integer operateType;

    private String name;

    AppOperateProcessEnum(Integer operateType, String name) {
        this.operateType = operateType;
        this.name = name;
    }

    public static AppOperateProcessEnum getByOperateType(int operateType) {
        for (AppOperateProcessEnum appOperateProcessEnum : values()) {
            if (Objects.equals(appOperateProcessEnum.getOperateType(), operateType)) {
                return appOperateProcessEnum;
            }
        }

        return UNKNOW;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
